package com.yitiao.data_algorithms.leetcode.editor.cn;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

class Finding3DigitEvenNumbers {
    // 2023-02-06 13:41:46
    public static void main(String[] args) {
        Solution solution = new Finding3DigitEvenNumbers().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int[] findEvenNumbers(int[] digits) {
            Set<Integer> set = new HashSet<>();
            int len = digits.length;
            for (int i = 0; i < len; i++) {
                if (digits[i] == 0) {
                    continue;
                }
                for (int j = 0; j < len; j++) {
                    if (j == i) {
                        continue;
                    }
                    for (int k = 0; k < len; k++) {
                        if (k == i || k == j || digits[k] % 2 != 0) {
                            continue;
                        }
                        int num = digits[i] * 100 + digits[j] * 10 + digits[k];
                        set.add(num);
                    }
                }
            }
            int size = set.size();
            int[] res = new int[size];
            int index = 0;
            for (int num : set) {
                res[index++] = num;
            }
            Arrays.sort(res);
            return res;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}